package com.yulebaby.callsenter.task;

import android.app.Activity;

import com.lzy.okgo.model.HttpParams;
import com.yulebaby.callsenter.bean.CustomerBean;
import com.yulebaby.callsenter.global.Constant;
import com.yulebaby.callsenter.http.HttpHelper;
import com.yulebaby.callsenter.http.ServerUrls;
import com.yulebaby.callsenter.http.callback.HttpCallback;
import com.yulebaby.callsenter.utils.GsonUtil;
import com.yulebaby.callsenter.utils.SPUtil;

/**
 * Author: Zhangbo
 * Time: 2016/11/28
 */
public class UploadCustomerTask {
    /**
     * 更新用户信息
     *
     * @param bean
     */
    public static void doUploadCustomerInfo(Activity activity, CustomerBean bean, HttpCallback callback) {
        if (bean != null) {
            String json = GsonUtil.parseBeanToJson(bean);
            HttpParams httpParams = new HttpParams();
            String user_token = (String) SPUtil.get(Constant.USER_TOKEN, "");
            int user_id = (int) SPUtil.get(Constant.USER_ID, -1);
            httpParams.put("token", user_token);
            httpParams.put("sale_id", user_id);
            httpParams.put("customer_id", bean.getCustomer_id());
            httpParams.put("customer", json);
            HttpHelper.getInstance().post(activity, ServerUrls.OPT_UPDATECUSTOMERINFO, httpParams, callback);
        }
    }

    /**
     * 抢客户
     */
    public static void doRobCustomer(Activity activity, Long customerId, HttpCallback callback) {
        HttpParams httpParams = new HttpParams();
        String user_token = (String) SPUtil.get(Constant.USER_TOKEN, "");
        int user_id = (int) SPUtil.get(Constant.USER_ID, -1);
        httpParams.put("token", user_token);
        httpParams.put("sale_id", user_id);
        httpParams.put("customer_id", customerId);
        HttpHelper.getInstance().post(activity, ServerUrls.OPT_ROBCUSTOMER, httpParams, callback);
    }


    /**
     * 投公海
     */
    public static void doThrowCustomerInternationalWater(Activity activity, Long customerId, HttpCallback callback) {
        HttpParams httpParams = new HttpParams();
        String user_token = (String) SPUtil.get(Constant.USER_TOKEN, "");
        int user_id = (int) SPUtil.get(Constant.USER_ID, -1);
        httpParams.put("token", user_token);
        httpParams.put("sale_id", user_id);
        httpParams.put("customer_id", customerId);
        HttpHelper.getInstance().post(activity, ServerUrls.OPT_THROWCUSTOMERINTERNATIONALWATER, httpParams, callback);
    }
}
